package collegemenu;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.TextField;

import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.JButton;
import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
// 수강내역
public class register extends JPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JTable table;

	/**
	 * Create the panel.
	 */
	public register() {
		table();
		panel();
	}
private void table(){
	setLayout(new BorderLayout(0, 0));
	
	table = new JTable();
	table.setModel(new DefaultTableModel(
	  new Object  [][] {
			  {"물리","이범상","교양필수","그냥책이야","2",null},
					{"물리1","이범상1","교양필수1","1","2",null},			
				
					
		
		},
		new String[] {
			"과목명","담당교수","과목구분","교과목소개","학점","신청"
		}
	) {
		/**
		 * 
		 */
		
		Class[] columnTypes = new Class[] {
			Object.class, Object.class, Object.class, Object.class, Object.class, Boolean.class
		};
		public Class getColumnClass(int c) {
			return columnTypes[c];
		}
	});
	JScrollPane scrollPane = new JScrollPane(table);
	add(scrollPane);
	table.setPreferredSize(new Dimension(400, 250));
}
	

private void panel(){
	JPanel panel_1 = new JPanel();
	panel_1.setPreferredSize(new Dimension(10, 30));
	add(panel_1, BorderLayout.SOUTH);
	panel_1.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
	
	JButton btnNewButton = new JButton("수강신청");
	btnNewButton.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			
			boolean val = (boolean)table.getValueAt(0, 5);
			boolean val1 = (boolean)table.getValueAt(1, 5);
			boolean val2 = (boolean)table.getValueAt(2, 5);
			boolean val3 = (boolean)table.getValueAt(3, 5);	// 값
			boolean val4 = (boolean)table.getValueAt(4, 5);
			boolean val5 = (boolean)table.getValueAt(5, 5);
			boolean val6 = (boolean)table.getValueAt(6, 5);
			boolean val7 = (boolean)table.getValueAt(7, 5);
			boolean val8 = (boolean)table.getValueAt(8, 5);
			boolean val9 = (boolean)table.getValueAt(9, 5);
			boolean val10 = (boolean)table.getValueAt(10, 5);
			boolean val11 = (boolean)table.getValueAt(11, 5);
			boolean val12 = (boolean)table.getValueAt(12, 5);
			
			/*System.out.println(val + "" + val1 + "" + val2 + "" + val3 + ""  + "" + val4 + "" + val5 + ""  + val6 + ""
					 + val7 + "" + val8 + "" + val9 + "" + val10 + "" + val11  + "" + val12);
			String sum = val + "" + val1 + "" + val2 + "" + val3 + ""  + "" + val4 + "" + val5 + ""  + val6 + ""
					 + val7 + "" + val8 + "" + val9 + "" + val10 + "" + val11  + "" + val12;
			System.out.println(sum);
				
			JOptionPane.showConfirmDialog(null, "신청하시겠습니까?","신청창",JOptionPane.YES_NO_OPTION,JOptionPane.INFORMATION_MESSAGE);
			JOptionPane.showMessageDialog(null, "수강신청되었습니다.");
			
				JOptionPane.showMessageDialog(null,"선택하여주세요");
			}*/
	
		}
		
	});
	panel_1.add(btnNewButton);
	}
}
	// 값
	
	

